package scuts.core.macros;
import utest.Assert;


import scuts.core.macros.F;
/**
 * ...
 * @author $(DefaultUser)
 */

class FnTest 
{

  public function new () { }
  
  public function test1() 
    {
      var f = F.n(_ * 2);
      Assert.same(4, f(2));
    }
  
  public function test2() 
    {
      var f = F.n(a = a * 2);
      Assert.same(4, f(2));
    }
  
  public function test3() 
    {
      var f = F.n(a,b = a * b);
      Assert.same(6, f(2,3));
    }
    
  public function test4() 
    {
      var f = F.n('a:String','b:String' = a + b);
      Assert.same("foobar", f("foo","bar"));
    }
  
  public function test5() 
    {
      var firstEl = F.n(_[0]);
      var a = [1, 2];
      Assert.same(1, firstEl(a));
    }
    
  public function test6() 
    {
      var o = { foo : 17 };
      var getFoo = F.n(_.foo);
      
      Assert.same(17, getFoo(o));
    }
    
   public function test7() 
    {
      var o1 = { foo : 3 };
      var o2 = { foo : 2 };
      var mulFoo = F.n(a,b = a.foo * b.foo);
      
      Assert.same(6, mulFoo(o1,o2));
    }
}